﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AiFrame.InterfaceLib.Resources;
using AiFrameDemo.Contacts.Core;

namespace AiFrameDemo.Contacts.WinForms.Windows
{
    public partial class ContactsListFrame : ContactsListFrameBase
    {
        public ContactsListFrame()
        {
            InitializeComponent();
        }

        public override void BringWindowToFront()
        {
            base.BringWindowToFront();
            ShowToolBar();
        }

        private void ShowToolBar()
        {
            ResourceImages resourceImages = new ResourceImages();

            ToolStrip toolStripButtons = new ToolStrip();
            ToolStripButton newButton = new ToolStripButton("Add a new contact...", resourceImages.DatasetAdd, OnToolItemClick);
            newButton.Tag = "New";
            toolStripButtons.Items.Add(newButton);

            ToolStripButton openButton = new ToolStripButton("Show...", resourceImages.DatasetOpen, null);
            openButton.Tag = "Open";
            toolStripButtons.Items.Add(openButton);

            ToolStripButton deleteButton = new ToolStripButton("Delete", resourceImages.DatasetDelete, null);
            deleteButton.Tag = "Delete";
            toolStripButtons.Items.Add(deleteButton);

            ToolStripButton saveButton = new ToolStripButton("Save", null, OnToolItemClick);
            saveButton.Tag = "Save";
            toolStripButtons.Items.Add(saveButton);

            ContactsRegistry.Instance.CoreInterface.ToolBarManager.AddToolGroup(toolStripButtons, false, 1);
        }

        private void OnToolItemClick(object sender, EventArgs e)
        {
            switch ((sender as ToolStripItem).Tag.ToString())
            {
                case "New":
                    _viewModel.UserWantsToAddContact();
                    break;
                case "Save":
//                    _viewModel.UserWantsToSaveCustomer();
                    break;

            }
        }
    }

}
